home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pesquisa Dirigida
/
Pesquisa Dirigida.iso
/
JOGOS
/
mini_putt2.swf
/
scripts
/
DefineSprite_201
/
frame_4
/
DoAction.as
Wrap
Text File
|
2005-01-07
|
6KB
|
274 lines
if(xdir < 0)
{
xcnt = xdir * -1;
}
else
{
xcnt = xdir;
}
if(ydir < 0)
{
ycnt = ydir * -1;
}
else
{
ycnt = ydir;
}
if(xcnt < ycnt)
{
cnt = ycnt;
}
else
{
cnt = xcnt;
}
ymod = ydir / cnt;
xmod = xdir / cnt;
x_old2 = ball._x;
y_old2 = ball._y;
i = 0;
while(i < cnt)
{
x_old = ball._x;
y_old = ball._y;
ball._x += xmod;
s = 1;
while(ss >= s)
{
if(ball.hittest(eval("s" add s)))
{
tellTarget("../sound")
{
gotoAndStop("bounce");
}
ball._x = x_old;
xmod *= -1;
xdir *= -1;
}
s++;
}
ball._y += ymod;
t = 1;
while(ts >= t)
{
if(ball.hittest(eval("t" add t)))
{
tellTarget("../sound")
{
gotoAndStop("bounce");
}
ball._y = y_old;
ymod *= -1;
ydir *= -1;
}
t++;
}
dr = 0;
while(drs >= dr)
{
if(ball.hittest(eval("dr" add dr)))
{
if(eval("on_dr" add dr) != "y")
{
tellTarget("../sound")
{
gotoAndStop("bounce");
}
x_anc = eval("dr" add dr add "._x");
y_anc = eval("dr" add dr add "._y");
if(ball._y < y_anc)
{
area = "t";
}
else
{
area = "b";
}
if(ball._x < x_anc)
{
area = area add "l";
}
else
{
area = area add "r";
}
if(area == "tl")
{
if(ymod == 0 or xmod == 0)
{
ymod2 = xmod * -1;
xmod2 = ymod * -1;
}
else if(0 < xmod and 0 < ymod)
{
ymod2 = xmod * -1;
xmod2 = ymod * -1;
}
else if(0 < xmod and ymod < 0)
{
ymod2 = xmod * -1;
xmod2 = ymod * -1;
}
else if(xmod < 0 and 0 < ymod)
{
ymod2 = xmod * -1;
xmod2 = ymod * -1;
}
}
else if(area == "tr")
{
if(ymod == 0 or xmod == 0)
{
ymod2 = xmod * 1;
xmod2 = ymod * 1;
}
else if(0 < xmod and 0 < ymod)
{
ymod2 = xmod * 1;
xmod2 = ymod * 1;
}
else if(xmod < 0 and 0 < ymod)
{
ymod2 = xmod * 1;
xmod2 = ymod * 1;
}
else if(xmod < 0 and ymod < 0)
{
ymod2 = xmod * 1;
xmod2 = ymod * 1;
}
}
else if(area == "bl")
{
if(ymod == 0 or xmod == 0)
{
ymod2 = xmod * 1;
xmod2 = ymod * 1;
}
else if(0 < xmod and 0 < ymod)
{
ymod2 = xmod * 1;
xmod2 = ymod * 1;
}
else if(0 < xmod and ymod < 0)
{
ymod2 = xmod * 1;
xmod2 = ymod * 1;
}
else if(xmod < 0 and ymod < 0)
{
ymod2 = xmod * 1;
xmod2 = ymod * 1;
}
}
else if(ymod == 0 or xmod == 0)
{
ymod2 = xmod * -1;
xmod2 = ymod * -1;
}
else if(0 < xmod and ymod < 0)
{
ymod2 = xmod * -1;
xmod2 = ymod * -1;
}
else if(xmod < 0 and 0 < ymod)
{
ymod2 = xmod * -1;
xmod2 = ymod * -1;
}
else if(xmod < 0 and ymod < 0)
{
ymod2 = xmod * -1;
xmod2 = ymod * -1;
}
ymod = ymod2;
xmod = xmod2;
ball._x += xmod;
ball._y += ymod;
ydir = ymod * cnt;
xdir = xmod * cnt;
checktimes += 1;
set("on_dr" add dr,"y");
tellTarget("dr" add dr)
{
gotoAndStop(1);
}
}
}
else
{
set("on_dr" add dr,"n");
}
dr++;
}
onhill = "no";
hr = 1;
while(hrs >= hr)
{
if(ball.hittest(eval("hr" add hr)))
{
xdir += hill;
onhill = "yes";
}
hr++;
}
hl = 1;
while(hls >= hl)
{
if(ball.hittest(eval("hl" add hl)))
{
xdir -= hill;
onhill = "yes";
}
hl++;
}
hu = 1;
while(hus >= hu)
{
if(ball.hittest(eval("hu" add hu)))
{
ydir -= hill;
onhill = "yes";
}
hu++;
}
hd = 1;
while(hds >= hd)
{
if(ball.hittest(eval("hd" add hd)))
{
ydir += hill;
onhill = "yes";
}
hd++;
}
i++;
}
speed = ydir * ydir + xdir * xdir;
if(speed < 20)
{
if(ball.hittest(hole))
{
gotoAndPlay(6);
}
}
else if(speed < 90)
{
if(ball.hittest(hole))
{
ydir *= 0.7 + random(6) / 10;
xdir *= 0.7 + random(6) / 10;
}
}
if(0.02 < speed)
{
ydir *= 0.96;
xdir *= 0.95;
}
else
{
ydir = 0;
xdir = 0;
prevFrame();
}